package cn.btks.backstagemanage.unit.repository;

import cn.btks.backstagemanage.unit.pojo.Unit;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author lijun
 * @Date 2021/1/13 13:04
 */
@Repository
public interface UnitRepository extends JpaRepository<Unit,Long>, JpaSpecificationExecutor<Unit> {

    /**
     * 删除单位信息
     * @param id
     * @return
     */
    @Modifying
    @Query(value = "delete from unit where id = ?1",nativeQuery = true)
    int deleteUnitById(Long id);

    /**
     * 根据所属师查询
     * @param cityId
     * @return
     */
    List<Unit> findAllByCityId(Long cityId);
}
